/**
 * 
 */
package photosalvage.entity;

import java.util.Date;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

import org.hibernate.annotations.Index;

/**
 * @author shumpei
 * 
 */
@Entity
@Table(name="PHOTO")
@org.hibernate.annotations.Table(appliesTo = "PHOTO", indexes = {
		@Index(name = "IDX_PHOTO_NUM", columnNames = "NUM"),
		@Index(name = "IDX_PHOTO_STATUS", columnNames = "STATUS"),
		@Index(name = "IDX_PHOTO_ORIGINAL_FILE_NAME", columnNames = "ORIGINAL_FILE_NAME"),
		@Index(name = "IDX_PHOTO_RETOUCHEDL_FILE_NAME", columnNames = "RETOUCHED_FILE_NAME")})
public class Photo {

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE)
	private Long id;

	@Embedded
	@AttributeOverrides({
			@AttributeOverride(name = "fileName", column = @Column(name = "ORIGINAL_FILE_NAME")),
			@AttributeOverride(name = "lastModified", column = @Column(name = "ORIGINAL_LAST_MODIFIED")) })
	private PhotoData original;

	@Embedded
	@AttributeOverrides({
			@AttributeOverride(name = "fileName", column = @Column(name = "RETOUCHED_FILE_NAME")),
			@AttributeOverride(name = "lastModified", column = @Column(name = "RETOUCHED_LAST_MODIFIED")) })
	private PhotoData retouched;

	@Column(name = "NUM", nullable = false, length=8)
	private String number;

	@ManyToOne
	private Album album;

	@Column(nullable = false, length=16)
	@Enumerated(EnumType.STRING)
	private PhotoStatus status;

	@ManyToOne
	private User uploadedBy;

	@Column(name = "UPLOADED_AT", nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date uploadedAt;

	@ManyToOne
	private User retouchedBy;

	@Column(name = "RETOUCH_STARTED_AT")
	@Temporal(TemporalType.TIMESTAMP)
	private Date retouchStartedAt;

	@Column(name = "RETOUCH_FINISHED_AT")
	@Temporal(TemporalType.TIMESTAMP)
	private Date retouchFinishedAt;

	@Version
	private Long version;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	public Album getAlbum() {
		return album;
	}

	public void setAlbum(Album album) {
		this.album = album;
	}

	public PhotoStatus getStatus() {
		return status;
	}

	public void setStatus(PhotoStatus status) {
		this.status = status;
	}

	public User getUploadedBy() {
		return uploadedBy;
	}

	public void setUploadedBy(User uploadedBy) {
		this.uploadedBy = uploadedBy;
	}

	public Date getUploadedAt() {
		return uploadedAt;
	}

	public void setUploadedAt(Date uploadedAt) {
		this.uploadedAt = uploadedAt;
	}

	public User getRetouchedBy() {
		return retouchedBy;
	}

	public void setRetouchedBy(User retouchedBy) {
		this.retouchedBy = retouchedBy;
	}

	public Date getRetouchStartedAt() {
		return retouchStartedAt;
	}

	public void setRetouchStartedAt(Date retouchStartedAt) {
		this.retouchStartedAt = retouchStartedAt;
	}

	public Date getRetouchFinishedAt() {
		return retouchFinishedAt;
	}

	public void setRetouchFinishedAt(Date retouchFinishedAt) {
		this.retouchFinishedAt = retouchFinishedAt;
	}

	public Long getVersion() {
		return version;
	}

	public void setVersion(Long version) {
		this.version = version;
	}

	public PhotoData getOriginal() {
		return original;
	}

	public void setOriginal(PhotoData original) {
		this.original = original;
	}

	public PhotoData getRetouched() {
		return retouched;
	}

	public void setRetouched(PhotoData retouched) {
		this.retouched = retouched;
	}
}
